#include<cstdio>
#include<iostream>
#include<algorithm>

const int N = 2e5 + 5;
int n, a[N];

int ans = -1; bool color[N];

inline int val() {
    int ret = 0;
    for(int i = 1; i <= n; ++i) {
        int pos = -1;
        for(int j = i - 1; j >= 1; --j) {
            if(color[j] == color[i]) {
                pos = j;
                break;
            }
        }
        if(pos != -1) ret += a[i] * (a[i] == a[pos]);
    }
    return ret;
}

void solve_dfs(int i) {
    if(i == n) {
        ans = std::max(ans, val());
        return ;
    }

    color[i + 1] = 1; solve_dfs(i + 1);
    color[i + 1] = 0; solve_dfs(i + 1);
}

inline void solve() {
    std::cin >> n;
    for(int i = 1; i <= n; ++i) {
        std::cin >> a[i];
    }

    solve_dfs(0);
    std::cout << ans << "\n";

    ans = -1;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0), std::cout.tie(0);

    std::freopen("color.in", "r", stdin);
    std::freopen("color.out", "w", stdout);

    int t; std::cin >> t;
    for(; t; --t) solve();

    return 0;
}
